package com.example.as_sum.fragment;


import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.as_sum.R;

import java.util.Random;

public class MainFourFragment extends BaseFragment {

    private TextView fragment_tv;
    public static MainFourFragment newInstance() {
        MainFourFragment fragment = new MainFourFragment();
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    private Handler mHandler=new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(Message msg) {
            closeDialog();
            switch (msg.what){
                case 0:
                    fragment_tv.setTextColor(Color.BLUE);
                    fragment_tv.setTextSize(20);
                    Random random=new Random();
                    int code= random.nextInt(100);
                    fragment_tv.setText("刷新完成了...，随机值："+code);
                    break;
                case 1:
                    break;
            }
            return false;
        }
    });
    @Override
    public void fetchData() {
        showDialog("刷新中...",false);
        mHandler.sendEmptyMessageDelayed(0, 1000);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_main_four, container, false);
    }

    @Override
    public void initView(View view) {
        fragment_tv=(TextView)view.findViewById(R.id.fragment_four_tv);
    }

    @Override
    public void addListener() {

    }

    @Override
    public void setParam() {

    }

    @Override
    public Handler getUIHandler() {
        return null;
    }

    @Override
    protected void loadUIData() {

    }
}
